import 'package:flutter/material.dart';
import 'package:ninetyfour/l10n/app_localizations.dart';
import '../view/logout_one_view.dart';
import '../../components/toast_utils.dart';
import '../controller/logout_pagetwo.dart';
import '../../manger/qysdk_manger.dart';
class LogoutPage extends StatelessWidget {
  final GlobalKey<LogoutOneViewState> logoutViewKey = GlobalKey();
  LogoutPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFFF8F6F7),
      appBar: AppBar(
        toolbarHeight: 40,
        title: Text(AppLocalizations.of(context)!.closeAccount,style: const TextStyle(fontSize: 17)),
        actions: [
          TextButton.icon(
            onPressed: () {
              QYSDK.showQYSession();
            },
            icon: Image.asset('assets/images/zhuxiao0.png'),
            label: Text(isChineseLocale() ? '客服' : 'Customer',style: const TextStyle(fontSize: 16)),
            style: TextButton.styleFrom(
              foregroundColor: Colors.black,
            ),
          ),
        ],
      ),
      body: Column(
      children: [
        SizedBox(
          height: 470,
          child: LogoutOneView(key: logoutViewKey),
        ),
        Padding(
          padding: const EdgeInsets.only(left: 35, right: 35, top: 20),
          child: ElevatedButton(
            style: ElevatedButton.styleFrom(
              backgroundColor: Colors.blue,
              foregroundColor: Colors.white,
              textStyle: const TextStyle(fontSize: 14),
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(20),
              ),
              minimumSize: const Size(double.infinity, 45),
            ),
            onPressed: () {
              final state = logoutViewKey.currentState;
              if (state == null || !state.isValidSelection) {
                ToastUtils.showCenterToast(context, AppLocalizations.of(context)!.selectLogoutReason,);
                return;
              }
              // 执行后续导航逻辑
              Navigator.push(context, MaterialPageRoute(builder: (_) => ZhuxiaoStepTwoPage(reasonText: state.reasonController.text,)));
            },
            child: Text(AppLocalizations.of(context)!.nextone),
          ),
        ),
      ],
    ),
    );
  }
}